package com.example.mybatis.controller;

import com.example.mybatis.mapper.UserMapper;
import com.example.mybatis.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.List;

/**
 * @Author: zll
 * @Date @{DATE} 21:49
 */
@RestController
public class TestController {

    @Autowired
    UserMapper userMapper;

    @RequestMapping("getList")
    public List<User> getList (){
        return userMapper.selectAll();
    }

    @RequestMapping("get")
    public List<User> get (){
        return userMapper.selectAll();
    }

    @RequestMapping("save/{count}")
    public  String test (@PathVariable("count") int count){
        String temp = "";
        for (int i = 0; i <count ; i++) {
            User user = new User();
            user.setNickName("zll");
            user.setPassword("123123");
            user.setUsername("asdfsdf");
            user.setSex(1);
            user.setRegisterDate(new Date());
            userMapper.insert(user);
            temp +=" -- "+user.getId();
        }

        return  "插入"+temp;
    }

}
